<extend name="layout/index"/>
<block name="content">
    <link rel="stylesheet" href="/static/admin/css/style.css" />
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>编辑</h5>
                    </div>
                    <div class="ibox-content">

                        <form role="form" class="form-horizontal m-t" method="post">
                            <input type="hidden" name="id" value="{$info.id}">
                            <div class="form-group draggable">
                                <label class="col-sm-3 control-label">banner名称：</label>
                                <div class="col-sm-9">
                                    <input type="text" name="title" class="form-control" placeholder="请输入文本" value="{$info.title}">
                                </div>
                            </div>
                            <div class="form-group draggable">
                                <label class="col-sm-3 control-label">跳转链接：</label>
                                <div class="col-sm-9">
                                    <input type="text" name="url" class="form-control" placeholder="请输入链接" value="{$info.url}">
                                </div>
                            </div>
                            <div class="form-group draggable">
                                <label class="col-sm-3 control-label">排序：</label>
                                <div class="col-sm-9">
                                    <input type="number" name="sort" class="form-control" placeholder="请输入数字，数字越大，排序越前" value="{$info.sort}">
                                </div>
                            </div>
                            <div class="form-group draggable">
                                <label class="col-sm-3 control-label">上传图片：</label>
                                <div class="input-file-show col-sm-2">
                                    <input type="hidden" id="image" name="image" value="{$info.image}" class="type-file-text form-control">
                                    <input type="button" name="button" value="选择上传..." onclick="GetUploadify('img_call_back')" class="type-file-button form-control layui-btn">
                                    <div class="putrue">
                                        <img id="userimg_i" class="fa fa-picture-o" src="{$info.image}" alt=""/>
                                    </div>
                                </div>

                            </div>
                            <div class="form-group draggable">
                                <label class="col-sm-3 control-label">状态：
                                </label>

                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="status" checked=""  value="1">
                                        展示
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="status" <eq name="info.status" value="0">checked</eq> value="0" >
                                        隐藏
                                    </label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable">
                                <div class="col-sm-12 col-sm-offset-3">
                                    <button class="btn btn-primary" type="button">保存内容</button>
                                    <button class="btn btn-white" type="reset">取消</button>
                                </div>
                            </div>
                        </form>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</block>
<block name="js">
    <script>
        //上传文件后，更改路径
        function img_call_back(fileurl_tmp) {
            $("#image").val(fileurl_tmp);
            $("#userimg_i").attr('src',fileurl_tmp); //layer.open('<img src="+fileurl_tmp+">',this,{tips: [1, '#fff']});
        }
        $(".btn-primary").click(function(){
         //   alert($("form").serialize());
            $.ajax({
                type : "post",
                url : "{:url('banner/edit')}",
                data : $("form").serialize(),
                dataType : "json",
                success : function(data) {
                    layer.msg(data.msg);
                    if (data.code==1) {
                        location.href=data.url;;
                    }
                },
                error : function(err) {
                    layer.alert(err.info, 8);
                }
            });
        })
    </script>
</block>

